<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<ul>
		<li>1</li>
		<li>2</li>
		<li>3</li>
		<li>4</li>
	</ul>
	<script type="text/javascript">
		var li = document.getElementsByTagName('li');
		for(var i = 0;i < li.length;i ++) {
			(function (n) {
				li[i].addEventListener('click',function () {
					console.log(n);
				},false);
			} (i));
		}
	</script>
</body>
</html>